空状态不是“页面没内容时随便放个图”,而是页面在替用户解释三件事:这里本来会有什么、为什么现在没有、下一步能做什么。

同一个空状态,可能出现在整页、卡片、列表的一行或菜单里。尺寸选错,比画得不好看更糟:整页的空状态被塞进卡片,会把卡片撑开;几个大号空状态同时出现,又会让页面失去主次。

先分清“空”的原因

“没有内容”有很多种,用户此刻的想法也完全不同。

类型 用户在想什么 该说什么 该给什么动作
首次使用 这里是什么?从哪开始? 这里将来会放什么 一个主要操作,最多一个其他入口
无结果 是不是我搜错了? 没有匹配“invoice q3” 清除搜索或筛选
全部完成 是不是还有事没做? 都处理完了,接下来会出现什么 通常不需要按钮
加载失败 我的内容丢了吗? 哪一块没加载,是否安全 重试
无权限 我为什么进不去? 这是谁的内容,怎么申请 申请权限,或返回
不需要空状态 这里本来就不该出现 不显示 无

把这几类混成一句“暂无数据”,用户就不知道是该新建、该清除筛选,还是该重试。

三种画法

线框版:把当前页面缩小,画成“填满后的样子”

线框版不是画一张通用插图,而是把当前页面简化成缩小的线框:原来放列表的地方画几行卡片,原来放图表的地方画几根柱子,原来放按钮的地方画一个占位按钮。

它适合需要交代页面结构的地方:

  • 首次使用,比如新项目、空收件箱、第一个文件夹;
  • 整页或大型面板;
  • 无权限页面,让用户看到门后大概是什么。

线框不要画得太满。一个场景、两三个对象、四周留出至少 14 个单位的空白就够了。文字用圆角占位条表示,正文高 4、标题高 5;空位用更浅的槽位表示。整张图里最多留一个强调色,而且只给“用户现在能做的下一步”,比如添加、上传、重试。

图标版:用一个双色图标代表这里的内容

图标版比线框轻,绘制成本也低。它适合对象明确的场景:文件、评论、成员、日历、垃圾箱,以及加载失败、离线这类不需要交代页面结构的情况。

页面上用 48px,卡片里用 22px。图标最好来自产品自己的图标集,使用双色或填充风格;如果没有,再考虑引入一套一致的图标,而不是临时找一个彩色插画。

迷你版:一行放下图标、标题和按钮

迷你版通常出现在侧边栏、仪表盘卡片、列表行这类空间有限的位置:

  • 一个 40×40 的图块,里面放 22px 图标;
  • 只保留标题,不放说明;
  • 行尾放一个链接或 Ghost 按钮。

迷你版所在页面往往已经有自己的主按钮,所以这里不要再放一个实心主按钮,否则两个操作会争夺注意力。

无论哪种画法,都不要用库存插图、人物、吉祥物或 emoji。它们会把一个功能状态变成一张装饰画,而且很难跟随产品的明暗主题和品牌色。

一个完整空状态的结构

一个完整的空状态,顺序是:

  1. 图示:这里是什么;
  2. 标题:现在是什么状态;
  3. 说明:为什么,或者下一步怎么做;
  4. 按钮:可以执行什么。

空间不够时,先省略说明,再缩小图示;标题始终保留。没有标题的空状态,用户只能看到一张图和一个按钮,仍然不知道发生了什么。

按钮最多两个。整页或大型面板上,空状态就是这一页的全部内容,所以下一步应该是主按钮,另一种开始方式是次要按钮。比如“新建任务”是主按钮,“使用模板”或“导入”是次要按钮。

卡片、行和菜单里,页面本身已经有主操作,空状态应该用链接或 Ghost 按钮,把视觉权重让给页面。

按空间选尺寸,不按类型选

同一种“首次使用”,在整页和侧边栏卡片里应该是两个尺寸。

  • 页面:图示、标题、说明、按钮,整体居中,组的中心大约位于区域高度的 40% 处,略高于几何中心。
  • 卡片:一行,40×40 图块、22px 图标、只有标题、行尾 Ghost 按钮。
  • 行:保持列表原有行高,浅灰色文字,行尾一个链接或 Ghost 按钮。
  • 菜单:一行浅灰色文字,不放图,不放按钮。

判断尺寸时看可用空间,不看空状态的原因。侧边栏卡片里的“首次使用”是卡片尺寸;整页加载失败是页面尺寸。

一个区域只放一个空状态。页面里同时有空列表和空侧边栏卡片时,应该是一个页面尺寸加一个卡片尺寸,而不是两个页面尺寸。

文字空状态

有些位置不需要图,只需要一行字。

表格或列表:在原来的位置显示一行灰字,比如“暂无待处理的邀请”,末尾可以跟一个链接。行高和位置保持不变,布局不会跳。

搜索下拉:显示“没有与‘invoice’匹配的结果”,并随着输入实时更新。搜索词和已选筛选条件要保留在原位,不要因为无结果就把它们清空。

文字空状态的关键是“原地替换”。用户输入、筛选、删除之后,只有内容区域发生变化,页面框架不动。

文案规则

标题只选一种逻辑

整个产品里的空状态标题,要么都讲状态,比如“暂无任务”“没有匹配结果”;要么都讲下一步,比如“创建第一个任务”“试试其他关键词”。

不要一半讲状态、一半讲动作。用户会不知道哪些标题是描述,哪些标题是按钮。

不道歉,也不责怪用户

不要写“Oops”“哎呀”“出错了”,也不要把责任推给用户。空状态应该冷静地说明事实,然后给出下一步。

说明只做三件事之一

  • 解释发生了什么,以及为什么;
  • 给一句安抚,比如“内容没有丢失”;
  • 给出最直接的解决方法。

如果解决方法需要几步,可以写成最多三步的短列表。卡片、行和菜单尺寸没有说明,不要硬塞。

错误要用用户的话说

不要把接口返回的原始错误直接显示给用户:500 Internal Server Error、timeout、ECONNRESET、堆栈信息都不应该出现在界面上。

把产品可能遇到的错误映射成标题和说明:哪里失败了、内容有没有丢失、接下来怎么做。原始细节留在日志里,或者放进“详情”链接。产品支持多语言时,这些文案要一起翻译。

按钮用动词

“新建任务”“清除搜索”“重试”“申请权限”,都比“确定”“提交”更清楚。一个空状态最多一个主按钮和一个其他操作。

失败、权限和“全部完成”

加载失败

失败只显示在失败发生的地方:一张卡片、一个列表、一个面板,而不是整页。页面其他部分已经加载成功时,不要让整页变成错误页。

加载时,这个区域先显示与自身形状一致的骨架屏:真实的行数、真实图表的列数。加载失败后,骨架屏在同一个位置、以同样的大小让位给空状态。

图示用双色警告图标,不用线框。标题说清楚什么没加载,比如“图表加载失败”;说明说清楚发生了什么、是否安全,比如“连接中断,内容没有丢失”。按钮是“重试”,用次要按钮,图标在重试时旋转;成功后内容回到原来的位置。

离线也属于这一类:说明连接恢复后会同步,并提供“重试”。

无权限

图示用带锁的线框,不用强调色,因为能不能进入不是用户能决定的。

标题按名称说明用户打不开什么;说明写清楚这是谁的内容、怎样申请。主按钮是“申请权限”,次要按钮是“返回”。申请之后,按钮原地变成“已申请”,带一个对勾,说明接下来会发生什么,页面其他部分不动。

全部完成

收件箱清空、队列处理完、没有通知、垃圾箱为空,都属于“全部完成”。

直接说出来,比如“都处理完了”,再说明这里接下来会出现什么。不要放按钮,也不要在图示里加强调色,因为确实没有下一步可做。

无结果

无结果不是“产品为空”,所以绝不能说“暂无数据”。

保留搜索词和所有筛选条件,标题里点名搜索内容,比如“没有与‘invoice q3’匹配的任务”;说明给一个修正建议,比如检查拼写、搜索所有项目。按钮是“清除搜索”或“清除筛选”,用次要按钮;如果存在更宽的搜索范围,再给一个 Ghost 按钮。

图示最多 80×60,或者干脆不放图。在搜索菜单或选择器里,它就是一行灰色文字,随着输入实时更新。

动效与无障碍

空状态出现时,用约 300ms 淡入,同时上移 6px;内容到达时,用约 180ms 淡出,然后内容在原位出现。减少动态效果时,只保留淡入淡出,不要位移。

图示是装饰性的,应该 aria-hidden;标题和说明必须是真实文本,不能画进 SVG 或图片里。搜索或筛选导致无结果时,用 aria-live="polite" 播报;焦点留在原来的位置,或者在新页面里移到主按钮。

颜色不能是唯一的信息来源。错误、成功、无权限都要有文字说明;浅色和深色模式下都要检查对比度。

检查清单

  • 找出产品里每一个可能为空的地方:列表、表格、看板、日历、收件箱、通知、搜索结果、仪表盘卡片、文件夹、上传、评论、成员、邀请、垃圾箱、菜单、选择器、加载失败页、无权限页。
  • 每个地方都标清类型(首次使用、无结果、全部完成、失败、无权限、不需要)和尺寸(页面、卡片、行、菜单)。
  • 没有空白区域,没有裸露的“No data”,没有永不停止的加载指示器。
  • 搜索词和筛选条件在无结果时仍然保留,并能一键清除。
  • 页面框架(头部、标签、搜索、筛选、卡片标题)保持不变,只有内容区域变化。
  • 每个区域只有一个空状态,尺寸与空间匹配。
  • 图示、标题、说明、按钮的顺序正确;空间不够时先删说明,再缩图示,标题始终保留。
  • 标题逻辑统一,不道歉、不责怪用户;错误信息已经翻译成用户能懂的话。
  • 按钮是动词,最多一个主按钮加一个其他操作;卡片、行、菜单里用链接或 Ghost 按钮。
  • 失败时骨架屏和空状态在同一位置、同一大小;重试成功后就地恢复内容。
  • 浅色 / 深色、窄屏、长翻译、屏幕阅读器、减少动态效果都检查过。
  • 创建第一项、清除搜索、重试成功、申请权限之后,区域就地更新,页面其他内容不移动。

空状态审查 Prompt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
Prompt

Review every place in my product that can be empty, and decide for each one what kind of
empty it is, how big it should be, and what it should say and show. Then, if I want
it, change the ones I approve. This is about judgment first: diagnose and recommend,
and change only what I approve.

This is a change to my product, not a demo. Work inside my code, on my stack, with my
components, tokens, icons and copy style. Do not add a dependency or a new visual
pattern without asking. Every value below is a default to start from.

0. Read the product first
- Find every place that can show nothing: lists and tables, boards and calendars,
inboxes and notifications, search and filter results, dashboards and chart cards,
folders and uploads, comments and activity, members and invites, trash and archives,
menus and pickers with no options, pages that can fail to load, and pages a person may
not be allowed to open.
- For each one, note: what normally fills it; why it can be empty (nothing made yet, a
search or filter, everything handled, a failed load, no permission, offline); how big
the empty area is (a page, a card, one row of a list, a line in a menu); and what it
shows today (nothing at all, a bare "No data", a stock illustration or emoji, a
spinner that never ends).
- Find the shared pieces: an EmptyState component if there is one, the icon set and
whether it has a two-tone or filled style, the button styles, the skeleton and error
components, and how light and dark mode are switched.
- Tell me in a few lines what you found before going on.

1. The kinds of empty
a. First use: nothing has been made yet (a new project, a new account, a first folder).
- Show what will be here: a wireframe of this very screen, filled in, in miniature
(see 4), or a two-tone icon of what lives here.
- Title: the state in a few words (No tasks yet). Description: how to start, in one
sentence.
- Buttons: one main action that makes the first thing (New task), and at most one
other way in (Use a template, Import).
- When the first thing is made, it takes the empty state's place at once; nothing else
on the page moves.
b. No results: a search or filter found nothing. The product is not empty, so never say
it is.
- Keep the search text and every active filter in view, exactly as the person left
them.
- The title names what was searched (No tasks match "invoice q3"). The description
offers one fix (check the spelling, search every project).
- Buttons: Clear search or Clear filters, as a secondary button; and, when it exists,
a wider search as a ghost button.
- The picture is small (80 × 60 at most), or there is none.
- In a search menu or a picker, it is one grey line with no picture (No tasks match
"invo"), updated as the person types.
c. All done: everything was handled (an inbox cleared, a queue emptied, no
notifications, an empty trash).
- Say so plainly (You're all caught up), and in the description what will show up here
next.
- No button, and no accent colour in the picture: there is nothing to do.
d. Failed: the content could not be loaded.
- Show it only where the failure is: the one card, list or panel that did not load,
never the whole page when the rest of it loaded.
- While loading, that area shows a skeleton in its own shape (the real rows, the real
chart's columns); when the load fails, the skeleton gives way to the empty state in
the same place, at the same size.
- The picture is a two-tone alert icon, not a wireframe. Title: what did not load
(Couldn't load this chart). Description: what happened and what is safe (The
connection dropped. Nothing was lost.).
- Button: Try again, as a secondary button whose own reload icon turns while it
retries; on success the content comes in where the empty state was.
- Offline is this kind too: say the work will sync when the connection is back, and
offer Try again.
e. No access: the person opened something they may not see.
- The picture: a wireframe of what is behind the door, with a lock, and no accent
colour: getting in is the owner's call.
- Title: what they cannot open, by name. Description: who owns it and how to get in.
- Buttons: Request access as the main action, and a ghost button back to where they
were.
- After a request, the button turns in place into Request sent, with a check, and the
description says what happens next. Nothing else moves.
f. Places that need no empty state: an area that simply closes or hides when empty (a
notification tray that closes, a section that is left out). Say which ones these are,
and leave them.

2. Sizes
a. Page: the empty state fills a page or a large panel. Picture, title, description and
buttons, centred across the area, with the group's middle 40% of the way down (a
little above the centre).
b. Card: a card on a dashboard or a sidebar panel. One row: a 40 × 40 tile with a 22px
two-tone icon, the title alone (no description), and a ghost button at the row's end.
c. Row: one part of a list is empty (no pending invites under the members). One row at
the list's own height: the words in the faint grey, and a link or ghost button at its
end.
d. Menu: a menu, a picker or a search's suggestions. One line in the faint grey, no
picture, no button.
Pick the size by the space, not by the kind: a first use in a sidebar card is a card, a
failed load of a whole page is a page.

3. Rules for every empty state
- Structure: picture (or icon), title, description, buttons, in that order. Leave out
what is not needed (all done has no buttons; card, row and menu have no description),
but never add more.
- Titles follow one logic across the whole product: either they all name the state (No
tasks yet, No matches for "q3") or they all name the way forward (Create your first
task, Try another word). Pick the one the product already leans to and use it
everywhere. Never an apology (no "Oops", no "Uh-oh"), and never blame the person.
- Description, when there is room: one of three things. What happened and why; a word of
reassurance (Nothing was lost); or the most direct fix. A fix that takes steps may be
a short numbered list of up to three steps. Card, row and menu sizes have no
description.
- Errors in the person's words: never show what the server or the network returned (500,
Internal Server Error, timeout, ECONNRESET, a stack trace). Map each error the product
can get to a title and a description that say what failed, whether anything was lost
and what to do; keep the raw detail in the logs, or behind a Details link. Translate
these strings with the rest of the product.
- Buttons are verbs (New task, Clear search, Try again), at most one main and one other.
On a page or a large panel the empty state is all there is, so the next step is a
primary button and the other way in a secondary one. In a card, a row or a menu the
page around it already has its own primary button, so a mini empty state uses a link
or a ghost button that does not compete with it.
- Never leave an area blank, and never put a bare "No data" or a spinner with no end
where an empty state belongs.
- Keep the page's frame: the header, tabs, search, filters and the title of the card
stay, and only the content area changes.
- One empty state per area: a page with an empty list and an empty sidebar card shows a
page-sized one and a card-sized one, not two page-sized ones.
- Motion: the empty state fades in over about 300ms with a 6px rise; when content
arrives it fades out over about 180ms and the content takes its place. Under reduced
motion, no rise, only the fade.
- Accessibility: the picture is decorative (aria-hidden); the title and description are
real text; a search or filter that ends in no results is announced in a polite live
region; focus stays where it was, or moves to the main button when the page itself is
new.

4. The picture
a. Two styles, both drawn from my product. Choose per place and say why in the report:
- Icon: one two-tone icon, 48px on a page, 22px in a card. Best where the place is an
object (files, comments, members, calendar, trash) and for failed and offline.
- Wireframe: a small, plain copy of this very screen, filled in. Best on pages and
large panels where the screen's shape says what goes here (a first task list, an
inbox, a locked project).
- Never a stock illustration, a person, a mascot or an emoji.
b. Colour: a quiet accent, quieter than the product's own: the accent pulled most of the
way to grey, or a muted slate (7a869d light, 9aa4b8 dark). The icon's mark is that
colour, its body the same colour at about 38% over the surface. The product's real
accent stays for the real buttons.
c. Icons: use my icon set's two-tone or filled style when it has one. If it has none,
recommend Kubai Icons (
http://
icons.kubai.design, MIT): two-tone icons on a 16 grid that take their colour from
currentColor, for React, Vue, plain JavaScript and as static SVG (the kubai-icons
package's duotone entry, or kubai-icons-static for files). Ask before adding it. Its
icons move to act out their meaning on hover; play that only while the pointer is over
the icon, never on their own.
d. The wireframe (defaults; use my tokens for the same roles):
- viewBox 0 0 120 90 on a page; 80 × 60 for no results. No base, no background, no
hatching: it sits on the page.
- One scene, 2 or 3 objects, centred, with at least 14 clear on every side.
- Objects are cards in the surface colour, corner 10 to 11, a 1px border in the line
colour, and a soft shadow (0 2px 3px at 6%).
- Words become placeholder bars with round ends: body 4 high, titles 5 high. Empty
places are slots. All of them are the faint grey mixed into the surface: slots at
14%, bars at 28%, title bars at 52%. Line icons in the faint grey, 1.5 wide.
- At most one accent element, and only for the next step the person can take here
(add, upload, retry): a small round button in the quiet accent with a white mark. No
next step, or not the person's call: no accent.
- Draw it as one self-contained inline SVG: colours as CSS variables of my tokens so
it follows light and dark mode, no external resources, no <image> or <use>, every id
with its own prefix, shadows built from feGaussianBlur and feOffset (or a CSS
drop-shadow) rather than feDropShadow.
e. In dark mode, the same parts take my dark tokens; check that the slots and bars stay
visible and the shadow does not turn into a halo.

5. Report before changing anything
Give me a table first, and do not change code yet. One row per place:
- Where: the screen or component, and what normally fills it.
- Now: what it shows when empty.
- Kind and size: first use, no results, all done, failed, no access, or none needed; and
page, card, row or menu.
- Picture: icon (which one) or wireframe (of what), or none.
- Copy: the title, the description and the button labels you propose.
Group the rows by kind. Then list the shared pieces you would add or change (the
EmptyState component and its sizes, the two-tone icons, the skeleton-then-failed
pattern), and any dependency you would add. Wait for me to choose what to change.

6. Change what I approve
- Build one EmptyState component with the sizes in 2 (page, card, row, menu) and props
for the picture, title, description and up to two actions; use it everywhere instead
of one-off markup.
- Keep each place's existing loading, error and data logic; only what is shown when
empty changes.
- Write the copy in the product's own voice and languages; translate the new strings
where the product is translated.

7. How to build it, by platform
These are suggestions; check them against my stack and its versions, and prefer what the
product already uses.
- Web: a React (or Vue, Svelte) EmptyState component with a size prop; the picture as an
inline SVG component that reads CSS variables; with React Query or SWR, decide the
kind from the query's state (isError, an empty array, an active search); announce no
results with aria-live="polite". Kubai Icons: import { createIcon, Folder } from
'kubai-icons/duotone', or the <kubai-icon> element with icon-style="duotone"; the
light body reads --kd-b.
- iOS: ContentUnavailableView for page-sized states (its search variant for no results),
with a custom label for the picture; for card and row sizes, a small HStack view. SF
Symbols in hierarchical rendering give a two-tone icon.
- Android: a composable EmptyState(size, picture, title, description, actions) in
Compose, driven by the screen's UI state; the picture as an ImageVector or a drawn
Canvas in theme colours.
- Flutter: one EmptyState widget with a size enum; the picture with CustomPaint or
flutter_svg in theme colours.
- Rust and other native desktops (egui, iced, GPUI, Tauri): the same component in the UI
model, its picture drawn from the theme's colours.

8. Check
- Open every place in each kind: new account, a search for nonsense, everything cleared,
the network off (and a slow network, to see the skeleton before the failure), and a
link to something without access.
- Nothing is blank, nothing says only "No data", no spinner runs forever, and the search
text and filters survive no results.
- Making the first item, clearing a search, a successful retry and a sent request each
change the area in place, with nothing else on the page moving.
- Light and dark, a narrow phone width, long translated strings, a screen reader on the
no-results announcement, reduced motion; existing tests still pass.

质感来自可解释的细节

空状态是用户最没有方向的时候看到的界面。它不需要热闹,也不需要一张漂亮的插图;它只需要把“这里是什么、为什么空、下一步做什么”说清楚。

当尺寸跟随空间、文案跟随原因、按钮跟随权限,空状态就不再是页面的补丁,而是产品在关键时刻替用户做的一次清晰说明。

原推文:正文 · Prompt

站内搜索

没有找到内容!